//
//  XPRZViewController.m
//  marrymarry
//
//  Created by caofeng on 16/9/25.
//  Copyright © 2016年 cf. All rights reserved.
//

#import "XPRZViewController.h"
#import "XueWeiRzViewController.h"
#import "PersonRZViewController.h"
#import "ZiChanViewController.h"
@interface XPRZViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *myScrollView;
@property (weak, nonatomic) IBOutlet UISegmentedControl *mySegmentControl;

@end

@implementation XPRZViewController




- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"self.other_idstr ===== %@ ",self.other_idStr);
    // Do any additional setup after loading the view.
     self.myScrollView.contentSize = CGSizeMake(ScreenWidth*2,0);
    UIStoryboard * xwsb = [UIStoryboard storyboardWithName:@"XPRZViewController" bundle:nil];
    if (self.isGotoJichanRenZhen == NO) {
        XueWeiRzViewController *XWVC =[xwsb instantiateViewControllerWithIdentifier:@"XueWeiRzViewController"];
        PersonRZViewController * PVC = [xwsb instantiateViewControllerWithIdentifier:@"PersonRZViewController"];
        XWVC.view.frame = CGRectMake(0,-35,self.myScrollView.frame.size.width, ScreenHeight);
        PVC.view.frame = CGRectMake(ScreenWidth, -35,self.myScrollView.frame.size.width, ScreenHeight);
        if (self.other_idStr != nil) {
            XWVC.otherid_str =self.other_idStr;
            PVC.otherid_str = self.other_idStr;
            NSLog(@"XWVC.otherid_str ========  %@",XWVC.otherid_str);
        }
        [self addChildViewController:XWVC];
        [self addChildViewController:PVC];
        [self.myScrollView addSubview:XWVC.view];
        [self.myScrollView addSubview:PVC.view];
    }else
    {
        [self.mySegmentControl setTitle:@"车辆认证" forSegmentAtIndex:0];
        [self.mySegmentControl setTitle:@"房产认证" forSegmentAtIndex:1];
        ZiChanViewController * zcVC = [xwsb instantiateViewControllerWithIdentifier:@"ZiChanViewController"];
        zcVC.ishouse=NO;
        zcVC.view.frame =CGRectMake(0,0,self.myScrollView.frame.size.width, ScreenHeight);
        ZiChanViewController * zcHouseVC = [xwsb instantiateViewControllerWithIdentifier:@"ZiChanViewController"];
        zcHouseVC.ishouse=YES;
        zcHouseVC.view.frame =CGRectMake(ScreenWidth, 0,self.myScrollView.frame.size.width, ScreenHeight);
        [self addChildViewController:zcVC];
        [self addChildViewController:zcHouseVC];
        [self.myScrollView addSubview:zcVC.view];
        [self.myScrollView addSubview:zcHouseVC.view];
        
    }
   
}
- (IBAction)choseVC:(UISegmentedControl *)sender {
    int index = (int)[sender selectedSegmentIndex];
    switch (index) {
        case 0:
            self.myScrollView.contentOffset = CGPointMake(0, 0);
        break;
        case 1:
            self.myScrollView.contentOffset = CGPointMake(ScreenWidth, 0);
        break;
        default:
        break;
    }
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.x ==ScreenWidth) {
        self.mySegmentControl.selectedSegmentIndex = 1;
        
    }else if (scrollView.contentOffset.x == 0)
    {
        self.mySegmentControl.selectedSegmentIndex = 0;
    }
}
- (IBAction)gobackVc:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
